<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Routing\Middleware\ThrottleRequests;

class ExThrottleRequests extends ThrottleRequests
{
    /**
     * Resolve request signature.
     *
     * @param  \Illuminate\Http\Request $request
     * @return string
     */
    protected function resolveRequestSignature($request)
    {
        $route = $request->route();

        $fingerprint = sha1(implode('|', array_merge(
            $route->methods(),
            [$request->getUri(), $request->ip()]
        )));
        return $fingerprint;
    }

    public function getRateLimiterKey($request)
    {
        return $this->resolveRequestSignature($request);
    }
}
